module.exports = {
  webpack: {
    configure(webpackConfig) {
      // 判断环境
      if (webpackConfig.mode === 'production') {
        webpackConfig.optimization.splitChunks = {
          chunks: 'all',
          cacheGroups: {
            antd: {
              name: 'antd-chunk',
              test: /antd/,
              priority: 10 // 权重
            },
            reactDom: {
              name: 'reactDom-chunk',
              test: /react-dom/,
              priority: 9 // 权重
            },
            vendors: {
              name: 'vendors-chunk',
              test: /node_modules/,
              priority: 8 // 权重
            }
          }
        }
      }
      return webpackConfig
    }
  },
  devServer: {
    client: {
      overlay: false // 解决开发环境下axios返回Promise.reject()时，全屏显示错误的问题
    },
    proxy: {
      '/api': {
        target: 'http://localhost:3003',
        changeOrigin: true,
        pathRewrite: { '^/api': '' }
      }
    }
  }
}
